import random

from app import app  # 离线脚本，该导入必不可少
from task_app.extensions import scheduler  # 离线脚本，该导入必不可少

ctx = app.app_context()
ctx.push()


def add_offline_task(task_id):
    print("离线脚本添加任务-%s" % task_id)


task_id = random.randint(1, 100)
scheduler.add_job(
    id="offline_task-%s" % task_id,
    func="task_app.tasks.offlineTaskDemo:add_offline_task",
    trigger="interval",
    seconds=30,
    args=[task_id],
    replace_existing=True
)
